package com.haoze.nurse.controller;

import com.haoze.common.response.Result;
import com.haoze.nurse.annotation.NurseActionLog;
import com.haoze.nurse.dto.NurseFormDTO;
import com.haoze.nurse.service.NurseCatalogService;
import com.haoze.nurse.service.NurseFormService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: Chenchao
 * @CreateTime: 2019-11-13 09:14
 */
@RestController
@RequestMapping("/nurse/catalog")
@Validated
@Api(value = "护理表单目录")
public class NurseCatalogController {

    @Autowired
    private NurseCatalogService nurseCatalogService;

    /**
     * 护理表单目录树
     */
    @GetMapping("/list")
    @ApiOperation(value = "获取目录数据")
    public Result list () {
        return nurseCatalogService.list();
    }


    /**
     * 获取表单+目录数据
     */
    @GetMapping("/formList")
    @ApiOperation(value = "获取表单数据")
    public Result formList (@RequestParam(defaultValue = "",required = false) final String id) {
        return nurseCatalogService.formList(id);
    }

    /**
     * 查询表单+目录数据
     */
    @GetMapping("/queryList")
    @ApiOperation(value = "获取表单数据")
    public Result queryList (@RequestParam(defaultValue = "",required = false) final String text,
                             @RequestParam(defaultValue = "",required = false) final String roleType,
                             @RequestParam(defaultValue = "",required = false) final String stopFlag) {
        return nurseCatalogService.queryList(text,roleType,stopFlag);
    }


    /**
     * 获取表单数据
     */
    @GetMapping("/getDetail")
    @ApiOperation(value = "获取表单数据详情")
    public Result getDetail (@RequestParam final String id,@RequestParam final String type) {
        return nurseCatalogService.getDetail(id,type);
    }

    /**
     * 修改表单数据
     */
    @PostMapping("/editDetail")
    @ApiOperation(value = "修改护理菜单设置")
    @NurseActionLog(value = "修改护理菜单设置")
    public Result editDetail (@RequestBody NurseFormDTO dto) {
        return nurseCatalogService.editDetail(dto);
    }


    /**
     * 修改表单+目录状态
     */
    @GetMapping("/changeStatus")
    @ApiOperation(value = "修改表单+目录状态")
    @NurseActionLog(value = "修改表单+目录状态")
    public Result changeStatus (@RequestParam String id,@RequestParam String type) {
        return nurseCatalogService.changeStatus(id,type);
    }

    /**
     * 新增目录
     */
    @PostMapping("/addCatalog")
    @ApiOperation(value = "获取目录数据")
    public Result addCatalog (@RequestBody NurseFormDTO dto) {
        return nurseCatalogService.addCatalog(dto);
    }


    /*-----------------------------2.2----------------------------------*/

    @GetMapping("/getNurseCatalog")
    @ApiOperation(value = "获取病历目录")
    public Result getNurseCatalog() {
        return nurseCatalogService.getNurseCatalog();
    }

    @GetMapping("/getTemplate")
    @ApiOperation(value = "获取目录下模板")
    public Result getTemplate(@RequestParam String catalogId, @RequestParam String roleType,@RequestParam Integer page,@RequestParam Integer pageSize) {
        return nurseCatalogService.getTemplateByCatalogId(catalogId, roleType, page, pageSize);
    }

}
